;(function($) {
	$.extend({
		ls : {
			get : function(key, defaultValue) {
				if(localStorage.getItem(key) === null)
					localStorage.setItem(key, defaultValue);
				return localStorage.getItem(key);
			},
			set : function(key, value) {
				localStorage.setItem(key, value);
			},
			remove : function(key) {
				localStorage.removeItem(key);
			},
			clear : function() {
				localStorage.clear();
			}
		},
		opt : {
			val : function(key, value) {
				if(value !== undefined)
					$.ls.set(key, value);
				return $.ls.get(key);
			},
			shortcut : {
				smart : function(value) {
					return $.opt.val("shortcut:smart", value);
				},
				smartActive : function(value) {
					return $.opt.val("shortcut:smart:active", value);
				},
				select : function(value) {
					return $.opt.val("shortcut:select", value);
				}
			}
		},
		shortcut : {
			exists : function(shortcut) {
				var arrShortcut = [];
				arrShortcut.push($.opt.shortcut.smart());
				arrShortcut.push($.opt.shortcut.smartActive());
				arrShortcut.push($.opt.shortcut.select());
				return jQuery.inArray(shortcut, arrShortcut) > -1 ? true : false;
			}
		}
	});
	$.fn.extend({
		ls : function() {
			this.each(function() {
				var elem = $(this);
				var key = elem.attr("name");
				var defaultValue = elem.val();
				elem.val($.ls.get(key, defaultValue));
				elem.keyup(function() {
					var elem = $(this);
					var key = elem.attr("name");
					var value = elem.val()
					$.ls.set(key, value);
				});
			});
		}
	});
})(jQuery);
